package com.lzl.consumer.task;

import com.lzl.common.GateWayPo;
import com.lzl.common.http.SimpleResponse;
import com.lzl.datas.dao.DbDao;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

public class ConsumerTask implements Runnable{

    GateWayPo po;

    DbDao dao;

    public ConsumerTask(GateWayPo po, DbDao dao) {
        this.po =  po;
        this.dao = dao;
    }

    @Override
    public void run() {
        System.out.println(po.toString());
        SimpleResponse response = new SimpleResponse();
        response.setContent(UUID.randomUUID().toString());
        dao.updateResponse(po.getId(), response);
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
